package com.lindainvest.util;

public class StringUtil {
	// 从东方财富客户端导出的数据, 结尾都是\t
	public static String trimTab(String str) {
		return (str.charAt(str.length() - 1) == '\t') ? str.substring(0,
				str.length() - 1) : str;
	}

	public static double convertToDouble(String str) {
		double retunValue = 0;
		try {
			str = trimTab(str);

			if (str.endsWith("万")) {
				String doubleStr = str.substring(0, str.lastIndexOf("万"));
				retunValue = Double.parseDouble(doubleStr) * 10000;
			} else {
				retunValue = Double.parseDouble(str);
			}
		} catch (Exception e) {
			retunValue = 0;
		}
		return retunValue;
	}

	public static void main(String[] args) {
		System.out.println(convertToDouble("4.45万	"));
	}
}
